package com.hziee.graduate.ticket.controller;


import com.hziee.graduate.ticket.dto.R;
import com.hziee.graduate.ticket.entity.User;
import com.hziee.graduate.ticket.service.UserService;
import com.hziee.graduate.ticket.vo.UserVO;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("user")
public class UserController {
    @Resource
    UserService userService;

    @GetMapping("/{id}")
    public R<User> getUserById(@PathVariable("id") Long userId) {
        return R.success(userService.getById(userId));
    }

    @PostMapping("/login")
    public R<UserVO> login(HttpSession session, @RequestBody Map<String, String> map) {
        return userService.login(session, map.get("phone"), map.get("password"));
    }

    @GetMapping("/getUserVO")
    public R<List<UserVO>> getUserVO() {
        return userService.getUserVO();
    }

    @PostMapping("/addCinemaManager")
    public R<UserVO> addCinemaManager(@RequestBody Map<String, Object> map) {
        return userService.addCinemaManager(map);
    }

    @PostMapping("/delCinemaManager")
    public R<UserVO> delCinemaManager(@RequestBody Map<String, Object> map) {
        return userService.delCinemaManager(map);
    }

    @PostMapping("/editCinemaManager")
    public R<UserVO> editCinemaManager(@RequestBody Map<String, Object> map) {
        return userService.editCinemaManager(map);
    }

    @PostMapping("/addBuyer")
    public R<Object> addBuyer(@RequestBody Map<String, Object> map) {
        return userService.addBuyer(map);
    }
}

